# from apitest import ApiTest
# from core import Codec
# import os
# from core import Func
# from core.util import StrUtil
# import importlib
# from cfg import GlobalCfg
from os import path
import random
from time import sleep
if __name__ == '__main__':
    nameTempList = ['wrh', 'cgs', 'zxh', 'gjh', 'zfl', 'zlt', 'zys', 'zzq', 'jnb', 'zj', 'sjh', 'lwh']
    qzDist = {'wrh': 0, 'cgs': 0, 'zxh': 0, 'gjh': 0, 'zfl': 0, 'zlt': 0, 'zys': 0, 'zzq': 0, 'jnb': 0, 'zj': 0, 'sjh': 0, 'lwh' : 0}
    namesList = []
    nameTmp = []

    runTimes = int(input('请输入次数:'))
    newDist = {}
    flag = True
    #无限循环， 直至出现
    while flag:
        nameList = nameTempList[:]
        #循环指定次数，或者权重列表
        for i in range(0, runTimes):
            if i > 0:
                nameList = nameTmp
                nameTmp = []

            tmpList = []
            #随机获取
            for j in range(0, 12):
                num = random.randrange(0, len(nameList))
                nameTmp.append(nameList.pop(num))
            namesList.append(nameTmp[:])

        for names in namesList:
            i = 1
            for name in names:
                qzDist[name] += i
                i += 1

        newDist = {v: k for k, v in qzDist.items()}
        #权重都不一致，完成算法，退出
        if len(newDist.keys()) == 12:
            flag = False

    newDist = sorted(newDist.items(), key=lambda e:e[0], reverse=False)
    for item in newDist:
        print(item)
        sleep(2)




